package com.xxzb.pack0720;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;

public class Test5 {
    public static void main(String[] args) throws Exception{
        Scanner sc=new Scanner(System.in);
        System.out.println("请您输入一个月份：");
        int month = sc.nextInt();
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql:///gaofeng2207?useSSL=false";
        String username="root";
        String password="1234";
        Connection conn= DriverManager.getConnection(url,username,password);
        String sql="select * from gaofeng2207.borrowinfo where month(borrowdate)=?";
        PreparedStatement ps=conn.prepareStatement(sql);
        ps.setInt(1,month);
        ResultSet rs = ps.executeQuery();
        while (rs.next()){
            int borrowId=rs.getInt(1);
            int bookId=rs.getInt(2);
            int readerId=rs.getInt(3);
            String borrowDate=rs.getString(4);
            String backDate=rs.getString(5);
            System.out.print("borrowId："+borrowId+"\t");
            System.out.print("bookId："+bookId+"\t");
            System.out.print("readerId："+readerId+"\t");
            System.out.print("borrowDate："+borrowDate+"\t");
            System.out.print("backDate："+backDate+"\n");
        }


    }
}
